package com.jt.tenant.db;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.zcx.helper.db.SQLiteTable;
import com.zcx.helper.db.note.SQLiteTableInfo;

import java.util.ArrayList;
import java.util.List;

@SQLiteTableInfo(name = "city", structure = { "abbr",  "city_code",	"city_name", "class_s",	"classno",	"engine", "engineno", "pId", "regist", "registno", "xuhao", "admin_code"})
public class JTCity extends SQLiteTable{

	public List<City> queryAll(String abbr){

		List<City> list = new ArrayList<>();

		SQLiteDatabase sqLiteDatabase = dataBase.getReadableDatabase();

		Cursor cursor = sqLiteDatabase.query("city", null, "abbr=?", new String[]{ abbr }, null, null, null);

		if (cursor.moveToFirst()) {

			do{

				City city = new City();

				city.abbr = cursor.getString(cursor.getColumnIndex("abbr"));

				city.city_code = cursor.getString(cursor.getColumnIndex("city_code"));

				city.city_name = cursor.getString(cursor.getColumnIndex("city_name"));

				city.class_s = cursor.getString(cursor.getColumnIndex("class_s"));

				city.classno = cursor.getString(cursor.getColumnIndex("classno"));

				city.engine = cursor.getString(cursor.getColumnIndex("engine"));

				city.engineno = cursor.getString(cursor.getColumnIndex("engineno"));

				city.pId = cursor.getString(cursor.getColumnIndex("pId"));

				city.regist = cursor.getString(cursor.getColumnIndex("regist"));

				city.registno = cursor.getString(cursor.getColumnIndex("registno"));

				city.xuhao = cursor.getString(cursor.getColumnIndex("xuhao"));

				city.admin_code = cursor.getString(cursor.getColumnIndex("admin_code"));

				list.add(city);

			}while (cursor.moveToNext());

		}

		return list;

	}

	public static class City{

		public String abbr, city_code, city_name, class_s, classno, engine, engineno, pId, regist, registno, xuhao, admin_code;

	}
	
}
